home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freaks Macintosh Archive
/
Freaks Macintosh Archive.bin
/
Freaks Macintosh Archives
/
Hacking & Misc
/
bundle of exploits.sit
/
bundle of exploits
/
ipscan.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-07-17
|
2KB
|
72 lines
/* IP Scan Version 1.1
* Coded by RooK
* Contact Information: rook@forfree.at
* http://www2.fwi.com/~rook/
*
* This is a simple to use and basic port scanner for Unix.
* To compile:
* gcc -s ipscan.c -o ipscan
*/
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include <netdb.h>
#include <signal.h>
#define VERSION "Version 1.1"
int main(int argc, char **argv)
{
int probeport = 0;
struct hostent *host;
int err, i, net;
struct sockaddr_in sa;
printf("--==[ IP Scan %s ]==--\n", VERSION);
printf(" by RooK\n\n");
if (argc != 2) {
printf("Usage: %s IP Address\n", argv[0]);
exit(1);
}
for (i = 1; i < 10001; i++) {
strncpy((char *)&sa, "", sizeof sa);
sa.sin_family = AF_INET;
if (isdigit(*argv[1]))
sa.sin_addr.s_addr = inet_addr(argv[1]);
else if ((host = gethostbyname(argv[1])) != 0)
strncpy((char *)&sa.sin_addr, (char *)host->h_addr, sizeof sa.sin_addr);
else {
herror(argv[1]);
exit(2);
}
sa.sin_port = htons(i);
net = socket(AF_INET, SOCK_STREAM, 0);
if (net < 0) {
perror("\nsocket");
exit(2);
}
err = connect(net, (struct sockaddr *) &sa, sizeof sa);
if (err < 0) {
printf("IP: %s Port: %-5d %s\r", argv[1], i, strerror(errno));
fflush(stdout);
} else {
printf("IP: %s Port: %-5d OPEN. \n", argv[1], i);
if (shutdown(net, 2) < 0) {
perror("\nshutdown");
exit(2);
}
}
close(net);
}
printf(" \r");
fflush(stdout);
return (0);
}